package com.hp.reflect;

public class TestReflect06 {
    public static void main(String[] args) throws ClassNotFoundException {
        //获取系统加载器;
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);//sun.misc.Launcher$AppClassLoader@18b4aac2

        //获取系统加载器的父类加载器;---->扩展类加载器;         jre\lib\ext
        ClassLoader systemClassLoaderParent = systemClassLoader.getParent();
        System.out.println(systemClassLoaderParent);//sun.misc.Launcher$ExtClassLoader@1b6d3586

        //获取扩展加载器的父类加载器--->根加载器; (使用C/C++写的;)     jre\rt.jar
        ClassLoader parent = systemClassLoaderParent.getParent();
        System.out.println(parent);//null

        //查看当前类 的 加载器;  ---->系统加载器;
        ClassLoader loader = Class.forName("com.hp.TestReflect06").getClassLoader();
        System.out.println(loader);//sun.misc.Launcher$AppClassLoader@18b4aac2

        //查看JDK内置类的加载器; --->根加载器
        ClassLoader loader1 = Class.forName("java.lang.Object").getClassLoader();
        System.out.println(loader1); //null

        //获取系统类加载器可加载的路径;
        System.out.println(System.getProperty("java.class.path"));
    }
}
